<?php
/**
 * 库存出库明细（国内库存出库记录）
 * (model)
 */

namespace App\Models\Inventory;

use App\Models\Product\ProductClassify;
use App\Models\Product\ProductSku;
use Illuminate\Database\Eloquent\Model;
class PlacingDetail extends Model
{
    protected $table = 'in_placing_detail';

    protected $guarded = [];

    public function placing(){
        return $this->belongsTo(Placing::class,'placing_no','placing_no');
    }

    public function sku(){
        return $this->belongsTo(ProductSku::class,'psku_id');
    }

    public function skuClassify(){
        return $this->hasOneThrough(
            ProductClassify::class,
            ProductSku::class,
            'id',//中间表
            'id',//目标表
            'psku_id',//当前模型
            'classify_id'//中间表
        );
    }
}
